﻿@model HotelManageSystem.Domain.Entities.Deliveryorder

@{
    Layout = "~/Views/Shared/_LayoutWarehouse.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="editGo" style="width: 100%;height: 100%">
    @using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <table>
            <ul>
                <tr>
                    <td> @Html.HiddenFor(model => model.DeliveryorderID)</td>
                </tr>
                <tr>
                    <td><h3>货品名：</h3></td>
                    <td>
                         @Html.DropDownList("productName")  库存数量： @Html.Raw("<input id='Iy' type='text'  disabled='disabled'/>")
                    </td>
                </tr>
                <tr>
                    <td><h3>出库单价：</h3></td>
                    <td>@Html.TextBox("Outprice")</td>
                </tr>
                <tr>
                    <td><h3>出库数量：</h3></td>
                    <td> @Html.TextBox("textcount")</td>
                </tr>
                <tr>
                    <td><h3>合计：</h3></td>
                    <td>@Html.TextBox("texttotal")</td>
                </tr>
                <tr>
                    <td><h3>出库时间：</h3></td>
                    <td> @Html.EditorFor(model => model.time)
                        @Html.ValidationMessageFor(model => model.time)
                    </td>
                </tr>
                <tr>
                    <td><h3>审核人：</h3></td>
                    <td> @Html.EditorFor(model => model.Billproducer)
                        @Html.ValidationMessageFor(model => model.Billproducer)
                    </td>
                </tr>
                <tr>
                    <td><h3>制单人：</h3></td>
                    <td>  @Html.DropDownList("employee")</td>
                </tr>
                <tr>
                    <td> <input  type="submit" value="保存" /></td>
                    <td>@Html.ActionLink("返回", "Index")</td>
                </tr>
            </ul>
        </table>
        <p>
           
        </p>
    </fieldset>
}
</div>

<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#productName").change(function () {
            //            var productNameid = $("#productName").attr("value");
            //            $("#Inventory").val(productNameid);
            $.getJSON("/Deliveryorder/GetInventory/", { productNameid: $("#productName").val() }, function (result) {
                if (result != 0) {
                    $(result).each(function () {
                        $("#textcount").keyup(function () {
                            var count = $("#textcount").attr("value");
                            if (count > result) {
                                alert("库存不足");
                            }
                        });
                        $("#Iy").val(result);
                    });
                }
                else {
                    $("#Iy").val(0);
                    alert("库存为0，请重新选择好出库货品");
                }
            });
        });
        $("#textcount").keyup(function () {
            var count = $("#textcount").attr("value");
            var price = $("#Outprice").attr("value");
            $("#texttotal").val(price * count);
        });
        $("#Outprice").keyup(function () {
            var price = $("#Outprice").attr("value");
            var count = $("#textcount").attr("value");
            $("#texttotal").val(price * count);
        });
        $(":submit").click(function () {
            var invent = $("#Iy").attr("value");
            if (invent == 0) {
                alert("货源不足不可出货");
                return false;
            }
            return true;

        });
    })
</script>